package com.bml.devops.demo.redis;

import org.redisson.Redisson;
import org.redisson.api.RBloomFilter;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;

public class RedissonBloomFilter {

    public static void main(String[] args) {
        Config config = new Config();
        config.useSingleServer().setAddress("redis://192.168.2.31:6379");
        RedissonClient client = Redisson.create(config);
        RBloomFilter<String> filter = client.getBloomFilter("urls");
        System.out.println(filter);
        filter.tryInit(100000000L,0.03);
        filter.add("baimaolin");
        //判断下面号码是否在布隆过滤器中
        System.out.println(filter.contains("bai"));//false
        System.out.println(filter.contains("maolin"));//false
        System.out.println(filter.contains("baimaolin"));//true
    }

}
